package com.example.statistics.bean

import android.os.Parcel
import android.os.Parcelable

data class FolderBean(
        var name: String? = null,
        var path: String = "",
        val checkedNum: Int = 0,
        val isChecked: Boolean = false,
        var documentList: MutableList<DocumentBean> = mutableListOf()
)

data class DocumentBean(
        var id: Int = 0,
        var path: String? = "",
        var name: String? = "",
        val duration: Long = 0,
        var isChecked: Boolean = false,
        var position: Int = 0,
        val num: Int = 0,
        var size: Long = 0L,
        val mimeType: String? = "",
        val mark: Int = 0 //唯一标示
) : Parcelable {
    constructor(parcel: Parcel) : this(
            parcel.readInt(),
            parcel.readString(),
            parcel.readString(),
            parcel.readLong(),
            parcel.readByte() != 0.toByte(),
            parcel.readInt(),
            parcel.readInt(),
            parcel.readLong(),
            parcel.readString(),
            parcel.readInt()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(id)
        parcel.writeString(path)
        parcel.writeString(name)
        parcel.writeLong(duration)
        parcel.writeByte(if (isChecked) 1 else 0)
        parcel.writeInt(position)
        parcel.writeInt(num)
        parcel.writeLong(size)
        parcel.writeString(mimeType)
        parcel.writeInt(mark)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<DocumentBean> {
        override fun createFromParcel(parcel: Parcel): DocumentBean {
            return DocumentBean(parcel)
        }

        override fun newArray(size: Int): Array<DocumentBean?> {
            return arrayOfNulls(size)
        }
    }
}